package guichatapplication;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

public class ListFriendCellRender extends JLabel implements ListCellRenderer {
  private static final Color HIGHLIGHT_COLOR = new Color(0, 0, 128);

  public ListFriendCellRender() {
    setOpaque(true);
    setIconTextGap(12);
  }

  public Component getListCellRendererComponent(JList list, Object value,
    int index, boolean isSelected, boolean cellHasFocus) {
    CustomListCell entry = (CustomListCell) value;
    String text=entry.getIdentify();
    if(entry.getIdentifies()!=null){
        for(String str: entry.getIdentifies()){
            text+=","+str;
        }
    }
    
    setText(text);
    setIcon(entry.getImage());
    if (isSelected) {
      setBackground(new Color(0,128,50));
      setForeground(Color.yellow);
        //setForeground(new Color(0,128,50));
    } else {
      setBackground(new Color(0,128,50));
      setForeground(Color.WHITE);
        //setForeground(Color.WHITE);
    }
    return this;
  }
}
